Optimize resolution by removing allocations
authorAlex Crichton <alex@alexcrichton.com>
Fri, 4 Nov 2016 00:18:48 +0000 (17:18 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 5 Jun 2017 14:36:44 +0000 (07:36 -0700)
commit48446574a6b3763f66d9a832481d379451d9ec91
tree7d0e5ae46126f1c45110802103c9d2dad4c655b8
parentaab5c348aa396070bb22f6be2de94caf6ecd5162
Optimize resolution by removing allocations

This commit is a relatively serious optimization pass of the resolution phase in
Cargo, targeted at removing as many allocations as possible from this phase.
Executed as an iterative loop this phase of Cargo can often be costly for large
graphs but it's run on every single build!

The main optimization here is to avoid cloning the context and/or pushing a
backtracking frame if there are no candidates left in the current list of
candidates. That optimizes a fast-path for crates with lock files (almost all of
them) and gets us to the point where cloning the context basically disappears
from all profiling.
Cargo.lock
src/bin/cargo.rs
src/cargo/core/resolver/mod.rs
src/cargo/lib.rs
src/cargo/util/graph.rs
tests/resolve.rs